package zz.demo.springCloud.filter;

import com.google.common.collect.Maps;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
import org.springframework.stereotype.Component;
import zz.demo.springCloud.adapter.RateLimiterAdapter;

import java.util.Map;

@Component
public class CanaryFilter extends ZuulFilter {
    private Map<String, RateLimiterAdapter> rateLimiterMap = Maps.newConcurrentMap();
    @Override
    public String filterType() {
        return FilterConstants.PRE_TYPE;
    }

    @Override
    public int filterOrder() {
        return 95;
    }

    @Override
    public boolean shouldFilter() {
        // TODO
        // 灰度发布开启条件
        return false;
    }

    @Override
    public Object run() {
        if(isCanary()){

        }else {

        }
        return null;
    }

    private boolean isCanary(){
        // TODO
        return true;
    }
}
